﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;

namespace UnitTestsDistributor
{
    /// <summary>
    /// this application aims to copy unit tests folder for a specified svn user to a mapped folder on SVN server 
    /// the svn user is read from app.config file
    /// MSUnitTestsFolderPath from app.config must be the same as MSUnitTestsFolderPath from app.config of PreCommitHook application, so keep them synchronized!!!
    /// </summary>
    class Program
    {
        protected static readonly ILog log = LogManager.GetLogger(typeof(Program));
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();
            string copyDirPath = "emtpy";
            
            if (args.Count() > 0)
            {
                try
                {

                    if (args.Count() == 2)
                    {
                        NetworkDriveMapper.CopyCSharpProjectFile(args[1]);
                        log.Info(String.Format("UnitTestsDistributor copying file {0}", args[1]));
                    }
                    else
                    {
                        copyDirPath = args[0];
                        NetworkDriveMapper.MapNetworkDrive();

                        NetworkDriveMapper.CopyUnitTestFolderContent(copyDirPath);
                        log.Info(String.Format("UnitTestsDistributor copying unit tests content from {0}", copyDirPath));
                    }
                }
                catch (Exception ex)
                {
                    log.Fatal(ex.Message);
                    throw;
                }
            }
          
            
         
        }
    }
}
